public class Main {
    public static void main(String[] args)
    {
//        System.out.println("Hello world!");
        Hanoi('A','B','C',3);
    }

    static void Hanoi(char a,char b,char c,int n)
    {
        if(n==1)
            System.out.println(a+"-->"+c);
        else
        {
            Hanoi(a,c,b,n-1);//a上面n-1移到b
            System.out.println(a+"-->"+c);//a第n移到c
            Hanoi(b,a,c,n-1);//需要把b上n-1移到c
        }
    }
}